from typing import Optional, List


class Solution:
    def removeDuplicates(self, s: str) -> str:
        if not s:
            return ''
        stack = []
        for i in range(len(s)):
            if stack and s[i] == stack[-1]:
                stack.pop()
            else:
                stack.append(s[i])
        return ''.join(map(str, stack))


so = Solution()
s = "abbaca"

print(so.removeDuplicates(s))
